﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;

namespace WebApplication4
{
    public partial class Alta_Provincia : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            SqlConnection conexion=new SqlConnection("Data Source=USUARIO-PC\\SQLEXPRESS;Initial Catalog=BDSAFA_01;Integrated Security=True;Pooling=False");
            conexion.Open();

            int codpais = (int)DropDownList1.SelectedIndex+1;
            String nombreprov = TextBox1.Text.ToString();

            SqlCommand comando = new SqlCommand("insert into PROVINCIA (descripcion,idPais) values ('" + nombreprov + "'," + codpais+")", conexion);

            if (comando.ExecuteNonQuery() > 0)
                Label1.Text = "Exito";
            else
                Label1.Text = "Error al grabar la BD";

            conexion.Close();
        }
    }
}